Sample Code - DrillOnDetail Event

This sample code shows the use of the DrillOnDetail Event (Window Object). Modify the following sample code to fit your needs.

Dim rpt As CRPEAuto.Report
Dim rptView As CRPEAuto.View
Dim test As Integer

Private Sub DrillOnDetail_Click()

'Starts up report window for window event DrillOnGroup
On Error GoTo ErrorHandler
Set rpt = crsApp.OpenReport("c:\crw\reports\xtreme\www.sales.rpt")
rpt.PrintWindowOptions.CanDrillDown = True
test = MsgBox("Event default: Enabled = " & _
    rpt.EventInfo.GroupEventEnabled & Chr(13) & Chr(13) & _
    "Disable event?", vbYesNo)
If test = vbYes Then
rpt.EventInfo.GroupEventEnabled = False
MsgBox "Check event does not occur when double click _
        on report detail field"
Else
rpt.EventInfo.GroupEventEnabled = True
'has useDefault but there is no default behaviour
MsgBox "Check event occurs when double click on report detail field"
End If
Set rptView = rpt.Preview
Set windowEvs = rptView.Parent
Exit Sub ' Exit to avoid handler.

ErrorHandler:
If crsApp.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & crsApp.LastErrorCode & _
        "->" & crsApp.LastErrorString
End If
If rpt.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & rpt.LastErrorCode & _
        "->" & rpt.LastErrorString
End If
If Err.Number <> 0 Then
MsgBox "Unexpected VB error: " & Err.Number & "->" & Err.Description
End If
Call ResetErr
rpt.ClearError
Resume Next
End Sub


Private Sub windowEvs_DrillOnDetail(ByVal FieldValues As Variant, _
    ByVal SelectedFieldIndex As Long, useDefault As Boolean)
'executed when drill on detail - test using default and _
'not using default behaviour
Dim x As Integer
For x = LBound(FieldValues) To UBound(FieldValues)
MsgBox "FieldValue" & x & " name: " & FieldValues(x).Name & _
        Chr(13) & "FieldValue" & x & " value: " & FieldValues(x).Value
Next x
MsgBox "Window DrillOnDetail event" & Chr(13) & Chr(13) & _
    "Parameters:" & Chr(13) & "Selected FieldValue name: " & _
    FieldValues(SelectedFieldIndex).Name & Chr(13) & _
    "Selected FieldValue value: " & FieldValues(SelectedFieldIndex).Value & _
    Chr(13) & "SelectedFieldIndex: " & SelectedFieldIndex & Chr(13) & _
    "useDefault: " & useDefault
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com